home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / kcl / kcl.lha / c / fasl_table.c < prev    next >
C/C++ Source or Header  |  1987-06-04  |  1KB  |  74 lines

  1. /*
  2. (C) Copyright Taiichi Yuasa and Masami Hagiya, 1984.  All rights reserved.
  3. */
  4.  
  5. /*
  6.     fasl_table.c
  7.     DG-SPECIFIC
  8. */
  9.  
  10. #include "include.h"
  11. #include "../h/fasl.h"
  12. #include "../h/fasl_global.h"
  13.  
  14. PART_TABLE_P
  15. fasl_new_table()
  16. {
  17.     PART_TABLE_P    table_p;
  18.  
  19.     if (((max_part_no + 1) % FAS_TABLES_IN_REC) == 0) {
  20.         /* assign new record */
  21.         fasl_write_temp();
  22.         fas_temp_curr = ++fas_temp_last;
  23.         zero(fas_temp_buff, FAS_BUFF_LEN);
  24.         }
  25.         else
  26.         /* there is a room in last record */
  27.         if (fas_temp_curr != fas_temp_last) {
  28.             fasl_write_temp();
  29.             fasl_read_temp(fas_temp_last);
  30.             }
  31.  
  32.     max_part_no++;
  33.     table_p = (PART_TABLE_P)fas_temp_buff +
  34.           max_part_no % FAS_TABLES_IN_REC;
  35.     table_p->part_no = max_part_no;
  36.     return(table_p);
  37. }
  38.  
  39. PART_TABLE_P
  40. fasl_get_table(base)
  41. short    base;
  42. {
  43.     int        rec_no;
  44.     PART_TABLE_P    table_p;
  45.  
  46.     rec_no = base / FAS_TABLES_IN_REC;
  47.     table_p = (PART_TABLE_P)fas_temp_buff +
  48.           base % FAS_TABLES_IN_REC;
  49.     if (rec_no == fas_temp_curr) return(table_p);
  50.  
  51.     /* we must flush current buffer ? */
  52.     if (fas_temp_flush == TRUE) fasl_write_temp();
  53.     fasl_read_temp(rec_no);
  54.  
  55.     return(table_p);
  56. }
  57.  
  58. int
  59. fasl_get_addr(base)
  60. {
  61.     int    recno, ind;
  62.  
  63.     if (base == vs_base_no) return(&vs_base);
  64.     if (base == vs_top_no) return(&vs_top);
  65.  
  66.     recno = base / FAS_ADDRS_IN_REC;
  67.     ind = base % FAS_ADDRS_IN_REC;
  68.  
  69.     if (recno != fas_addr_rec_curr)
  70.         fasl_read_addr_rec(recno);
  71.  
  72.     return( ((int *)fas_addr_buff)[ind] );
  73. }
  74.